import request from '@/common/request.js'

export function oilRecordStat(data, success) {
	return request({
		url: '/api/blade-energy/oilRecord/statistics?startDate=' + data.startTimeSeconds +
			'&endDate=' + data.endTimeSeconds,
		method: 'get',
		success
	})
}
export function checkOilMeasurePoint(data, success, fail, complete) {
	if (!data || !data.deviceId) {
		uni.showLoading({
			title: '请先选择用油设备',
			duration: 1000,
			icon: 'error'
		});
		return;
	}
	return request({
		url: '/api/blade-ami/bameasurepoint/listPoint?current=1&size=-1&deviceId=' + data.deviceId +
			'&dataTypeIds=' + data.oilType,
		method: 'get',
		success
	});
}

export function loadOilDeviceList(orgId, success, fail, complete) {
	return request({
		url: '/api/blade-oms/device/listByOrgAndEngType?current=1&size=-1&orgId=' + orgId + '&engtype=4',
		method: 'get',
		success,
		fail,
		complete
	});
}

export function loadDeviceCompanyList(success, fail, complete) {
	return request({
		url: '/api/blade-oms/building/listDept?pid=',
		method: 'get',
		success,
		fail,
		complete
	});
}

export function saveOilRecordData(data, success, fail, complete) {
	return request({
		url: '/api/blade-energy/oilRecord/save',
		method: 'post',
		data,
		success,
		fail,
		complete
	})
}

export function getBookList(data, success, fail, complete) {
	if (!data) {
		data = {};
	}
	if (!data.deviceName) {
		data.deviceName = "";
	}
	if (!data.orgId) {
		data.orgId = "";
	}
	const loadOilRecordUrl = '/api/blade-energy/oilRecord/page?oilWay=2&current=' + data.current + '&size=' + data
		.size +
		'&recordTimeRange=' + data.startTimeSeconds + '&recordTimeRange=' + data.endTimeSeconds + '&deviceName=' + data
		.deviceName + '&orgId=' + data.orgId;
	// console.log(loadOilRecordUrl);
	return request({
		url: loadOilRecordUrl,
		method: 'get',
		success,
		fail,
		complete
	})
}
export function deleteBook(data, success, fail, complete) {
	return request({
		url: '/App/Book/DeleteBook',
		method: 'Post',
		data,
		success,
		fail,
		complete
	})
}

export function checkUserAuth(data, success) {
	return request({
		url: '/api/zhny/oil_auth/check?oilUser=' + data.oilUser + '&userPwd=' + data.userPwd + '&operator=' +
			data.operator + '&operatorPwd=' + data.operatorPwd,
		method: 'get',
		success
	})
}

export function getDeviceInfo(assetCode, success) {
	return request({
		url: '/api/zhny/device/oileng/query?assetCode=' + assetCode,
		method: 'get',
		success
	})
}
